{extend name='admin'}
 {block name='css'}
<!--<link rel="stylesheet" type="text/css" href="{:asset('bootstrap-3.3.7/css/bootstrap.css')}"/>-->
 {/block}
 {block name='content'}
    <ul class="nav nav-tabs">
        <li role="presentation" ><a href="{:url('admin/index/index')}">首页</a></li>
        <li role="presentation" class="active"><a href="#">分类管理</a></li>
    </ul>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <ul class="nav nav-pills">
                <li role="presentation" class="active"><a id="add" href="#">添加分类</a></li>
                <li role="presentation"><a href="#">批量删除</a></li>
            </ul>
                <div class="result-content">
                    <table class="table table-hover">
                        <tr>
                            <th class="tc" width="5%">
                                <input class="allChoose" name="" type="checkbox">
                            </th>
                            <th>ID</th>
                            <th>分类名称</th>
                            <th>分类描述</th>
                            <th>分类图片</th>
                            <th>操作</th>
                        </tr>
                        {foreach $date as $item}
                        <tr>
                            <td class="tc">
                                <input name="id" value="{$item.id}" type="checkbox">
                            </td>
                            <td>{$item.id}</td>
                            <td >{$item.title}</td>
                            <td>{$item.content}</td>
                            <td>
                                <img src="http://www.blog.com/{$item.mylogo}" width="80px" alt="">
                            </td>
                            <td>
                                <a id="{$item.id}" class="btn btn-info link-update" href="#">修改</a>
                                <a id="{$item.id}" class="btn btn-danger link-del" href="#">删除</a>
                            </td>
                        </tr>
                        {/foreach}
                    </table>
                </div>
            </form>
            <nav aria-label="Page navigation">
                {$date|raw}
            </nav>
        </div>
    {/block}
{block name='js'}
<script>
    $(function(){
        $('#add').click(function(){
            layer.ready(function(){
                layer.open({
                    //弹出框样式
                    type:2,
                    //弹出框标题
                    title:'添加分类',
                    //是否全屏
                    maxmin:true,
                    //弹出框大小
                    area:['1000px','600px'],
                    content:"{:url('admin/cate/cateadd')}"
                })
            });
        });
        $('.link-update').click(function(){
            var id =$(this).attr('id');
            layer.ready(function(){
                layer.open({
                    type:2,
                    maxmin:true,
                    title:'修改分类',
                    area:['1000px','600px'],
                    content:"{:url('admin/cate/cateupd?id=')}"+id
                })
            })
        })
        $('.link-del').click(function(){
            var id =$(this).attr('id');
            $.ajax({
                url:"{:url('admin/cate/catedel')}",
                type:'get',
                data:{id:id},
                dataType:'json',
                success:function(msg){
                    if(msg==1){
                        layer.alert('删除成功',{icon:6},function(){
                            parent.location.reload();
                            window.location.href="{:url('admin/cate/index')}";
                        })
                    }else{
                        layer.alert('删除失败',{icon:5})
                    }
                }
            })
        })
    })
</script>
{/block}
{/extend}